package leetcode.code1624;

import java.util.Arrays;

public class Solution {
	public int maxLengthBetweenEqualCharacters(String s) {
		int[] l = new int[128];
		Arrays.fill(l, -1);
		int ans = -1;
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if (l[c] == -1) {
				l[c] = i;
			} else {
				ans = Math.max(ans, i - l[c] - 1);
			}
		}
		return ans;
	}
}
